<?php

class Install_Api_Check
{

    public $_vars = array();

    public function __construct()
    {
        $this -> _vars = array(
            'php' => array(
                'info' => 'require php version > 5.1.1',
                'current' => PHP_VERSION,
                'require' => '5.1.1',
                'isValid' => version_compare(PHP_VERSION, '5.1', '>')?'success':'failed',
            ),
            'mysql' => array(
                'info' => 'require mysql > 5.0',
                'current' => 'unkown',
                'require' => '5.0',
                'isValid' => 'success'
            ),
            'public_path' => array(
                'info' => 'public path',
                'current' => PUBLIC_PATH,
                'require' => 'writeable',
                'isValid' => is_writeable(PUBLIC_PATH)?'success':'failed',
            ),
            'temp_path' => array(
                'info' => 'temporary path',
                'current' => TEMP_PATH,
                'require' => 'writeable',
                'isValid' => is_writeable(TEMP_PATH)?'success':'failed',
            ),
            'log_path' => array(
                'info' => 'log path',
                'current' => LOG_PATH,
                'require' => 'writeable',
                'isValid' => is_writeable(LOG_PATH)?'success':'failed',
            ),
            'setting_path' => array(
                'info' => 'setting path',
                'current' => SETTING_PATH,
                'require' => 'writeable',
                'isValid' => is_writeable(SETTING_PATH)?'success':'failed',
            ),
            'cache_path' => array(
                'info' => 'cache path',
                'current' => CACHE_PATH,
                'require' => 'writeable',
                'isValid' => is_writeable(CACHE_PATH)?'success':'failed',
            ),'session_path' => array(
                'info' => 'session path',
                'current' => SESSION_PATH,
                'require' => 'writeable',
                'isValid' => is_writeable(SESSION_PATH)?'success':'failed',
            )
        );
    }

    /**
     * @param string $name
     * @return string
     */
    public function getInfo($name)
    {
        return $this -> _vars[$name]['info'];
    }

    /**
     * @param string $name
     * @return string
     */
    public function getRequire($name)
    {
        return $this -> _vars[$name]['require'];
    }

    /**
     * @param string  $name
     * @return string
     */
    public function getCurrent($name)
    {
        return $this -> _vars[$name]['current'];
    }

    /**
     * @param string $name
     * @return status success,warning, error
     */
    public function isValid($name)
    {
        return $this -> _vars[$name]['isValid'];
    }

}
